<template>
  <div>
    <common-header :tittle="tittle" :showback="false"></common-header>
    <div class="page-content">
      <mt-button @click="getVersion">获取版本信息</mt-button>
    </div>
  </div>
</template>

<script>
import { mapMutations, mapGetters, mapState } from "vuex";
import commonHeader from "common/common-header";
import * as homeApi from "api/home-api";
import { ERR_OK } from "config/index";
export default {
  data() {
    return {
      tittle: "我的页面",
      num: 0
    };
  },
  created() {},
  methods: {
    ...mapMutations({
      setNum: "SET_NUM"
    }),
    getVersion() {
      homeApi
        .get_ios_version()
        .then(res => {
          let { data } = res;
          console.log(data);
          if (data.success === ERR_OK) {
            alert(data.value.token);
          } else {
            this.$toast({
              message: data.data.versiondesc,
              position: "bottom",
              duration: 3000
            });
          }
        })
        .catch(() => {
          this.$toast({
            message: "操作失败",
            position: "bottom",
            duration: 3000
          });
        });
    }
  },
  components: {
    commonHeader
  },
  computed: {
    ...mapGetters(["number"]),
    ...mapState({
      number: state => state.home.number
    })
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
@import "~style/home.scss";
</style>
